import 'package:finance_app/src/entities/dashboard_reimburse_entity.dart';

dashboardReimburseEntityFromJson(DashboardReimburseEntity data, Map<String, dynamic> json) {
	if (json['title'] != null) {
		data.title = json['title'].toString();
	}
	if (json['currency_code'] != null) {
		data.currencyCode = json['currency_code'].toString();
	}
	if (json['total'] != null) {
		data.total = json['total'].toString();
	}
	if (json['chartData'] != null) {
		data.chartData = (json['chartData'] as List).map((v) => DashboardReimburseChartData().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> dashboardReimburseEntityToJson(DashboardReimburseEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['title'] = entity.title;
	data['currency_code'] = entity.currencyCode;
	data['total'] = entity.total;
	data['chartData'] =  entity.chartData?.map((v) => v.toJson())?.toList();
	return data;
}

dashboardReimburseChartDataFromJson(DashboardReimburseChartData data, Map<String, dynamic> json) {
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['value'] != null) {
		data.value = json['value'] is String
				? int.tryParse(json['value'])
				: json['value'].toInt();
	}
	return data;
}

Map<String, dynamic> dashboardReimburseChartDataToJson(DashboardReimburseChartData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['name'] = entity.name;
	data['value'] = entity.value;
	return data;
}